package com.dong.demo;

public class Point {
    //属性
    private double x;
    private double y;
    public Point(){

    }
    public Point(double x, double y){
        this.x=x;
        this.y=y;

    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }
    public void setXY(double x,double y){
        this.x=x;
        this.y=y;
    }
    public  void  moveX(double vx){
        x=vx;
    }
    public  void  moveY(double vy){
        x=vy;
    }
    public void moveXY(double vx,double vy){
        x+=vx;
        y+=vy;

    }
    //this:调用该方法的本点
    public double getDis(Point other){
//        double dis=Math.sqrt((this.x-other.x)*(this.y-other.y)+(this.y-other.y)*(this.y-other.y));
        double x = Math.abs(this.x - other.x);
        double y = Math.abs(this.y - other.y);
        double dis= Math.sqrt(x*x+y*y);
        return dis;
    }
    public double getSin(Point other){
       return Math.abs(this.x-other.y)/getDis(other);

        //Math.abs(this.y-other.y)/getDis(other)
    }
    public double getCos(Point other){

        return Math.abs(this.x-other.x)/getDis(other);
    }

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}
